import { Component, OnInit, Input, Output, EventEmitter, ElementRef, Renderer2 } from '@angular/core';
import { NavParams, Events, ModalController } from '@ionic/angular';

@Component({
    selector: 'key-inspection',
    templateUrl: 'key-inspection.html',
    styleUrls: ['key-inspection.scss'],
    // providers: [ElementRef]
})
export class KeyInspectionModal implements OnInit {
    @Input() alarmData;

    constructor(
        public events: Events,
        public modalCtrl: ModalController,
        // public el: ElementRef,
        // public renderer: Renderer2
    ) {
    }

    ngOnInit() {
        console.log(this.alarmData);
    }

    openRoom(data, index) {
        if (data.devAbnormalNum_room === 0) {
            return;
        }

        if (data.isOpen) {
            data.isOpen = false;
            // const ele = this.el.nativeElement.querySelector('.key-inspect-detail-move');
            // this.renderer.removeClass(ele, 'move-animation');
        } else {
            // const ele = this.el.nativeElement.querySelector('.key-inspect-detail-move');
            // this.renderer.addClass(ele, 'move-animation');
            for (let i = 0; i < this.alarmData.Info.length; i++) {
                if (index === i) {
                    data.isOpen = true;
                } else {
                    this.alarmData.Info[i].isOpen = false;
                }
            }
        }
    }

    close() {
        this.modalCtrl.dismiss();
    }
    openFile() {

    }
}
